/* SWFUpload Config */

$(function (){ createSWFUpload(); })

var upload;
function createSWFUpload(){
	upload = new SWFUpload({
		// Backend Settings
		upload_url: "member_diary.php", 
		post_params: { action : "localUpload", data : getPostParam() }, 
		
		// File Upload Settings
		file_size_limit : "8192",	// 1MB
		file_types : "*.jpg",
		file_types_description : "All Files",
		file_upload_limit : "0",
		file_queue_limit : "0",
		
		// Event Handler Settings (all my handlers are in the Handler.js file)
		file_dialog_start_handler : fileDialogStart,		// 当文件选取对话框弹出前出发的事件处理函数
		file_queued_handler : fileQueued,
		file_queue_error_handler : fileQueueError,
		file_dialog_complete_handler : fileDialogComplete,	// 当文件选取对话框关闭后触发的事件处理函数
		upload_start_handler : uploadStart,					// 开始上传文件前触发的事件处理函数
		upload_progress_handler : uploadProgress,
		upload_error_handler : uploadError,
		upload_success_handler : uploadSuccess,				// 文件上传成功后触发的事件处理函数
		upload_complete_handler : uploadComplete,
		
		// Button Settings
		button_image_url : "images/uploadbypc.png",			// uploadbypc.jpg
		button_placeholder_id : "uploadBotton",
		button_width: 186,
		button_height: 186,
		button_cursor : SWFUpload.CURSOR.HAND,				// 鼠標手勢
		
		// Flash Settings
		flash_url : "flash/swfupload/swfupload.swf",	
		custom_settings : {
			progressTarget : "uploadProgress",
			cancelButtonId : "cancel1Botton"
		},
					
		// Debug Settings
		debug: false
	});
}

/* 勾選日期排序 */
function addTripChange(){
	upload.setPostParams({ action : "localUpload", data : getPostParam() });
	return true;
}

/* 獲取POST參數 */
function getPostParam(){
	var saveDate = $("#saveDate").attr("checked") ? 1 : 0;
	return $.toJSON({ "diaryID" : diaryID, "tripID" : tripID, "memberID" : memberID, "msKey" : msKey, "saveDate" : saveDate });
}